package experiment;

import java.util.Scanner;

public class User {
    String name;
    public IOperation[] operations;
    public Scanner scanner = new Scanner(System.in);
    public User(String name){
        this.name = name;
        operations = new IOperation[]{
                new AddOperation(),     //添加操作
                new FindIOperation(),   //查询操作
                new DeleteIOperation(), //删除操作
                new ShowIOperation(),   //显示操作
                new UpdateIOperation(),  //修改操作
        };
    }
    public void doOperation(int choice,EmployeeList employeeList){
        operations[choice - 1].work(employeeList);
    }
    public int menu(){
        System.out.println("=========================");
        System.out.println("欢迎" + this.name + "使用员工系统");
        System.out.println("0.退出");
        System.out.println("1.添加操作");
        System.out.println("2.查询操作");
        System.out.println("3.删除操作");
        System.out.println("4.显示操作");
        System.out.println("5.修改操作");
        int choice = scanner.nextInt();
        System.out.println("=========================");
        if(choice == -1){
            close();
        }
        return choice;
    }
    public void close(){
        scanner.close();
    }
}
